<script setup lang="ts">
import {computed, type Reactive, reactive, ref} from "vue";
import Action from "@/modal/Action";
import {ActionName} from "@/components/type";
import Pop from "@/modal/Pop";

const action = reactive(Action.getInstance());
const pop = reactive(Pop.getInstance());

export interface iPop {
  show: boolean;
}

const props = defineProps<iPop>();
const show = computed(() => props.show);
const toggle = (actionType: ActionName) => {
  action.setAction([actionType]);
  emits('emitShow');
}
const emits = defineEmits(['emitShow'])
const textShow = (actionName: ActionName) => {
  switch (actionName) {
    case ActionName.FLOWER:
      return `花卉`;
    case ActionName.BEEHIVE:
      return `蜂巢`;
    case ActionName.FRUIT:
      return `果园`;
    case ActionName.TOOL:
      return `工具`;
    case ActionName.PLANT:
      return `种植`;
    case ActionName.WATER:
      return `灌溉`;
  }
}
</script>

<template>
  <div class="container-fluid pop-mask"
       :class="{choose: !show}"
  >
    <div class="pop user-select-none"
         :class="{choose: !show}">
      <div v-for="actionName in pop.actionsConfig" @click="toggle(actionName)">
        {{ textShow(actionName) + `行动+1` }}
      </div>
    </div>
  </div>
</template>

<style scoped>
.pop-mask.choose, .pop.choose {
  display: none;
}

.pop-mask {
  position: absolute;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, .15);
  z-index: 1;
}


.pop {
  position: fixed;
  left: calc(50% - 250px);
  top: calc(50% - 100px);
  width: 500px;
  height: 200px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  background-color: darkgreen;
  z-index: 1;
}

.pop div {
  width: 50%;
  height: 50%;
  border: 1px dashed darkgoldenrod;
  border-radius: 10px;
  text-align: center;
  line-height: 100px;
  color: white;
}
</style>